﻿using Klear.Library.Models;

namespace Klear.Library.Services;

public class GlobalSearchService : IGlobalSearchService
{
    private static IDatabaseService _databaseService;

    public GlobalSearchService(IDatabaseService databaseService) {
        _databaseService = databaseService;
    }
    
    //加载当月收支记录
    public async Task<IList<IncomeAndExpensesModel>> LoadIncomeAndExpensesAsync()
    {
        DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
        DateTime endTime = startTime.AddMonths(1).AddTicks(-1);
        return await _databaseService.GetIncomeAndExpensesAsync(startTime, endTime);
    }
    
    //加载类别
    public async Task<IList<CategoryModel>> LoadCategoriesAsync() {
        return await _databaseService.GetCategoriesAsync();
    }
    
    //加载搜索结果
    public async Task<IList<IncomeAndExpensesModel>> LoadSearchResultsAsync(string title, decimal amount,
        string category, string notes, DateTime createDate) {
        return await _databaseService.SearchIncomeAndExpensesAsync(title, amount, category, notes, createDate);
    }
    
    //搜索目标记录
    public void SearchIncomeAndExpenses() {
        throw new NotImplementedException();
    }
}